
/*
* CarTypeDAL
*/
using System;
using System.Collections;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;

using WHC.Pager.Entity;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Carmall.Entity;
using Carmall.IDAL;

namespace Carmall.DAL
{
	/// <summary>
	/// CarType DAL 的摘要说明。
	/// </summary>
	public class CarType : BaseDAL<CarTypeInfo>, ICarType
	{
		#region 对象实例及构造函数

		public static CarType Instance
		{
			get
			{
				return new CarType();
			}
		}
		public CarType() : base("cartype","TypeId")
		{
		}

		#endregion

		/// <summary>
		/// 将DataReader的属性值转化为实体类的属性值，返回实体类
		/// </summary>
		/// <param name="dr">有效的DataReader对象</param>
		/// <returns>实体类对象</returns>
		protected override CarTypeInfo DataReaderToEntity(IDataReader dataReader)
		{
			CarTypeInfo cartypeInfo = new CarTypeInfo();
			SmartDataReader reader = new SmartDataReader(dataReader);
			
			
			cartypeInfo.TypeId = reader.GetInt32("TypeId");
			cartypeInfo.Name = reader.GetString("Name");
            cartypeInfo.BrandID = reader.GetInt32("BrandID");
			cartypeInfo.Brand = reader.GetString("Brand");
			cartypeInfo.CarModel = reader.GetString("CarModel");
			cartypeInfo.Displacement = reader.GetString("Displacement");
			cartypeInfo.Size = reader.GetString("Size");

			
			return cartypeInfo;
		}

		/// <summary>
		/// 将实体对象的属性值转化为Hashtable对应的键值
		/// </summary>
		/// <param name="obj">有效的实体对象</param>
		/// <returns>包含键值映射的Hashtable</returns>
		protected override Hashtable GetHashByEntity(CarTypeInfo obj)
		{
			CarTypeInfo info = obj as CarTypeInfo;
			Hashtable hash = new Hashtable(); 
			
			
			hash.Add("TypeId", TypeHelper.SafeInt(info.TypeId));
			hash.Add("Name", TypeHelper.SafeString(info.Name));
            hash.Add("BrandID", TypeHelper.SafeInt(info.BrandID));
			hash.Add("Brand", TypeHelper.SafeString(info.Brand));
			hash.Add("CarModel", TypeHelper.SafeString(info.CarModel));
			hash.Add("Displacement", TypeHelper.SafeString(info.Displacement));
			hash.Add("Size", TypeHelper.SafeString(info.Size));

			
			return hash;
		}
	}
}
